package com.bigflexlib.utils
{
	import com.bigflexlib.core.dependency.EventDispatcherWithDependenciesBase;
	
	import mx.events.StateChangeEvent;




/**
 *  @eventType mx.events.StateChangeEvent.CURRENT_STATE_CHANGE
 */
[Event(name="currentStateChange", type="mx.events.StateChangeEvent")]	



	public class StateHolderWithDependencies extends EventDispatcherWithDependenciesBase
	{
		
		private var _currentState:String;
		[Bindable( "currentStateChange" )]
		public function get currentState( ):String
		{
			return _currentState;
		}		


		public function StateHolderWithDependencies( initialState:String = null )
		{
			_currentState = initialState;		
		}

		protected function setState( newState:String ):void
		{
			if ( _currentState == newState )
				return;
			
			var oldState:String = _currentState;
			
			_currentState = newState;
			
			dispatchEvent( new StateChangeEvent( StateChangeEvent.CURRENT_STATE_CHANGE, false, false, oldState, newState ) ); 
		
		}

	}
}